﻿using System.ComponentModel.DataAnnotations;
using Tanmia.Basis.Core;

namespace Tanmia.Warehouse.Core
{
    /// <summary>
    /// الفروع
    /// </summary>
    public class Branch : BaseBusinessObject
    {
        public override bool IsEmpty
        {
            get { return BranchID == 0; }
        }

        private int branchID;
        private string name;

        /// <summary>
        /// رقم تعريف الفرع
        /// </summary>
        [Display(Name = "رقم الفرع: ", ShortName = "رقم الفرع", Order = 0, AutoGenerateField = true)]
        public virtual int BranchID
        {
            get { return branchID; }
            set { SetValue<int>("BranchID", ref branchID, value); }
        }

        /// <summary>
        /// اسم الفرع
        /// </summary>
        [Display(Name = "اسم الفرع: ", ShortName = "اسم الفرع", Order = 1, AutoGenerateField = true)]
        [Required(AllowEmptyStrings = false, ErrorMessage = "يجب ادخال اسم الفرع قبل الإتمام.")]
        public virtual string Name
        {
            get { return name; }
            set { SetValue<string>("Name", ref name, value); }
        }

        public override bool Equals(object obj)
        {
            if (!base.Equals(obj)) return false;

            Branch branch = obj as Branch;

            if (!branch.BranchID.Equals(this.BranchID)) return false;

            return true;
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }
}
